s = []
while True:
    v = input()
    if v == 'end':
        break
    d = v.split()
    t = []
    for i in d:
        t.append(int(i))
    s.append(t)

m = []
for i in range(len(s)):
    next_i = i+1
    if next_i >= len(s):
        next_i = 0
    n = []
    for j in range(len(s[i])):
        next_j = j+1
        if next_j >= len(s[i]):
            next_j = 0
        n.append(s[i][j-1] + s[i][next_j] + s[next_i][j] + s[i-1][j])
    m.append(n)
g = ''
for i in m:
    t = ''
    for j in i:
        t += str(j) + ' '
    g += t[:-1] + '\n'
print (g)







